<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use common\models\City;
use yii\helpers\ArrayHelper;
$province = City::findBySql("select * from grp_city where id like '%0000'")->all();

/* @var $this yii\web\View */
/* @var $model backend\models\BuildCity */
/* @var $form yii\widgets\ActiveForm */
?>
<script type="text/javascript">
<!--
function selectprovince_id()
{
	var province_id = $("#buildcity-province_id").val();
	
	$("#buildcity-city_id").html('');	
	$.ajax({
		url:"index.php?r=build-city/select_province_id&province_id="+province_id,
		data:{},
		//dataType:"json",
		success:function(data){
			
			$("#buildcity-city_id").html(data);
			},	
		});
	}
//-->
</script>
<div class="build-city-form">

    <?php $form = ActiveForm::begin(); ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
    
     <?= $form->field($model, 'province_id')->dropDownList(ArrayHelper::map($province, 'id', 'name'),['onchange' => 'selectprovince_id()']) ?>

    <?= $form->field($model, 'city_id')->dropDownList(ArrayHelper::map($city, 'id', 'name')) ?>

    <?= $form->field($model, 'sort')->textInput() ?>

    <?= $form->field($model, 'search_index')->textInput(['maxlength' => true]) ?>

    <div class="form-group">
        <?= Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
